package SwordMeansOffer;

//跳台阶

public class JumpFloor {

    public int JumpFloor(int target) {
        if(target <= 2){
            return target;
        }

        int[] dp = new int[target + 1];
        dp[0] = 0;
        dp[1] = 1;
        dp[2] = 2;
        return jumpDp(target,dp);

    }

    public int jumpDp(int target , int[] dp){
        if(target <= 2){
            return target;
        }
        if(dp[target] > 0){
            return dp[target];
        }else{
            dp[target] = jumpDp(target - 1,dp) + jumpDp(target - 2 , dp);
        }
        return dp[target];
    }

}
